#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll a[100100],b[100100],c[100100];
ll ans;
ll maxx=0;
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        b[a[i]]++;
        maxx=max(a[i],maxx);
    }
    c[maxx]=0;
    for(int i=maxx-1;i>=1;i--)
    {
        c[i]=c[i+1]+b[i+1];
    }
    ll summ=0;
    for(int i=maxx;i>=1;i--)
    {
        if(b[i]<=c[i]-summ)
        {
            summ+=b[i];
        }
        else if(b[i]>c[i]-summ)
        {
            ans+=b[i]-c[i]+summ;
            summ=c[i];
        }
    }
    cout<<ans;
    return 0;
}